module.exports = {
  publicPath: '/',
  outputDir: 'dist',
  productionSourceMap: false, // 打包是否生成.map文件
  lintOnSave: 'warning', // eslint警告会在编译输出
  configureWebpack: { // 打包忽略文件
    externals: { // '别名' : '原名'
      'Vue': 'Vue',
      'VueRouter': 'VueRouter',
      'Vuex': 'Vuex',
      'axios': 'axios',
      'element-ui': 'ELEMENT',
      'echarts': 'echarts'
    }
  },
  devServer: {
    open: false, // 编译后自动打开
    inline: true, // 保存代码刷新页面
    host: 'localhost', // 自己的ipv4地址
    port: 4000, // 端口
    https: false, // 启用https
    proxy: { // 配置跨域
      '/api': {
        target: 'http://127.0.0.1:5000/api/',
        changOrigin: true, // 允许跨域
        pathRewrite: {
          '^/api': ''
        }
      },
    }
  },
  css: {
    loaderOptions: {
      sass: { // 给 sass-loader 传递选项
        prependData: `
                      @import "@/styles/mixin.scss";
                      @import "@/styles/global.scss";
                      @import "@/styles/common.scss";
                     `
      }
    }
  },
  pages: {
    index: {
      title: '专利查询系统',
      entry: 'src/main.js',
      template: 'public/index.html',
      filename: 'index.html',
      chunks: ['chunk-vendors', 'chunk-common', 'index'],
      cdn: {
        css: [
          'https://at.alicdn.com/t/font_2681766_h08stq5cxsf.css',
          'https://unpkg.com/element-ui/lib/theme-chalk/index.css', // element样式
        ],
        js: [
          'https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.min.js',
          'https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.8/vue-router.min.js',
          'https://cdn.bootcdn.net/ajax/libs/vuex/3.5.1/vuex.min.js',
          'https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js', // axios请求库
          'https://unpkg.com/element-ui/lib/index.js', // elementUI
          'https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js',
          'https://lib.baomitu.com/echarts/5.1.2/extension/dataTool.js'
        ]
      }
    }
  }
}
